{% extends "report/common/search_run.html" %}
{% block report %}
{% if report_data %}
	{% if queries %}
	<div class="queries">
		<ul>
		{% for k, v in queries.items %}
			<li><label>{{ k|title }}:</label>{{ v|safe }};</li>
		{% endfor %}
			<li class="clear"></li>
		</ul>
	</div>
	{% endif %}

	<div class="reportSummary01">
		<ul>
			<li>
				Plan:<span>{{ report_data.plans_count }}</span>
				Run:<span>{{ report_data.runs_count }}</span>
				Case-Run:<span>{{ report_data.caseruns_count }}</span>
			</li>
		</ul>
		<div class="clear"></div>
	</div>

	{% for tag_name, plans_count, runs_count, caseruns_count, matrix_rows in report_data.reports %}
	<div class="reportSummary01">
		<ul><li class="tagTab">Plan Tag: <span>{{ tag_name }}</span></li></ul>
		<ul>
			<li>Run:<span>{{ runs_count }}</span></li>
			<li>Plan:<span>{{ plans_count }}</span></li>
			<li>CaseRun:<span>{{ caseruns_count }}</span></li>
		</ul>
		<div class="clear"></div>
	</div>
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="listTdReport">
		<tr>
			<th class="w200">Build</th>
			<th>Plan</th>
			<th>Run</th>
			<th class="w50">Idle</th>
			<th class="w50">Running</th>
			<th class="w50">Paused</th>
			<th class="w50">Passed</th>
			<th class="w50">Failed</th>
			<th class="w50">Blocked</th>
			<th class="w50">Error</th>
			<th class="w50">Waived</th>
		</tr>
		{% for build, plan, run, status_subtotal in matrix_rows %}
		<tr>
			{% ifnotequal build.1 None %}
			<td rowspan="{{ build.1 }}" class="bgRowspan">{{ build.0.name }}</td>
			{% endifnotequal %}
			{% ifnotequal plan.1 None %}
			<td {% ifnotequal plan.1 1 %}rowspan="{{ plan.1 }}"{% endifnotequal %} class="bgRowspan">
				<a href="{% url 'test_plan_url_short' plan.0.pk %}">TP-{{ plan.0.pk }}: {{ plan.0.name }}</a>
			</td>
			{% endifnotequal %}
			<td><a href="{% url 'testruns-get' run.pk %}">{{ run.summary }}</a></td>
			<td><a href="{{ report_url }}{{path_without_build}}&r_build={{ build.0.pk }}&plan_tag={{ tag_name }}&run={{ run.pk }}&status=idle">{{ status_subtotal.IDLE|default:0 }}</a></td>
			<td><a href="{{ report_url }}{{path_without_build}}&r_build={{ build.0.pk }}&plan_tag={{ tag_name }}&run={{ run.pk }}&status=running">{{ status_subtotal.RUNNING|default:0 }}</a></td>
			<td><a href="{{ report_url }}{{path_without_build}}&r_build={{ build.0.pk }}&plan_tag={{ tag_name }}&run={{ run.pk }}&status=paused">{{ status_subtotal.PAUSED|default:0 }}</a></td>
			<td><a href="{{ report_url }}{{path_without_build}}&r_build={{ build.0.pk }}&plan_tag={{ tag_name }}&run={{ run.pk }}&status=passed">{{ status_subtotal.PASSED|default:0 }}</a></td>
			<td><a href="{{ report_url }}{{path_without_build}}&r_build={{ build.0.pk }}&plan_tag={{ tag_name }}&run={{ run.pk }}&status=failed">{{ status_subtotal.FAILED|default:0 }}</a></td>
			<td><a href="{{ report_url }}{{path_without_build}}&r_build={{ build.0.pk }}&plan_tag={{ tag_name }}&run={{ run.pk }}&status=blocked">{{ status_subtotal.BLOCKED|default:0 }}</a></td>
			<td><a href="{{ report_url }}{{path_without_build}}&r_build={{ build.0.pk }}&plan_tag={{ tag_name }}&run={{ run.pk }}&status=error">{{ status_subtotal.ERROR|default:0 }}</a></td>
			<td><a href="{{ report_url }}{{path_without_build}}&r_build={{ build.0.pk }}&plan_tag={{ tag_name }}&run={{ run.pk }}&status=waived">{{ status_subtotal.WAIVED|default:0 }}</a></td>
		</tr>
		{% endfor %}
	</table>
	{% empty %}
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="listTdReport">
		<thead>
			<tr>
				<th class="w200">Build</th>
				<th>Plan</th>
				<th>Run</th>
				<th class="w50">Idle</th>
				<th class="w50">Running</th>
				<th class="w50">Paused</th>
				<th class="w50">Passed</th>
				<th class="w50">Failed</th>
				<th class="w50">Blocked</th>
				<th class="w50">Error</th>
				<th class="w50">Waived</th>
			</tr>
		</thead>
		<tbody>
			<tr><td colspan="11" align="center">No report data.</td></tr>
		</tbody>
	</table>
	{% endfor %}
{% endif %}
{% endblock %}
